package com.tuozixuan.entity;

import java.math.BigDecimal;
import java.util.Iterator;

import org.springframework.data.util.Streamable;

public class Persons3 implements Streamable<Person> {
	
	private Streamable<Person> streamable;
	
	public Persons3(Streamable<Person> streamable) {
		this.streamable = streamable;
	}

	@Override
	public Iterator<Person> iterator() {
		return streamable.iterator();
	}
	
	public BigDecimal sumAmount() {
		return streamable.stream().map(Person::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
	}

}
